package com.sds.sweng.swat.miplatform.ui.design.models.area.sub;

import org.eclipse.ui.views.properties.IPropertyDescriptor;
import org.eclipse.ui.views.properties.PropertyDescriptor;

public class PagingSubArea extends SubArea {

	public static final int MINIMUM_WIDTH = 500;

	public static final String
		PAGING = "paging";

	static {
		descriptors = new IPropertyDescriptor[] {
			new PropertyDescriptor(PAGING, "Paging")
		};
	}

	private boolean paging;

	public PagingSubArea() {

	}

	public PagingSubArea clone() {
		PagingSubArea clone = (PagingSubArea) super.clone();
		clone.setPaging(isPaging());

		return clone;
	}

	public boolean isPaging() {
		return paging;
	}

	public void setPaging(boolean paging) {
		this.paging = paging;
		firePropertyChange(PAGING, null, paging);
	}

	public Object getPropertyValue(Object id) {
		if (PAGING.equals(id))
			return isPaging();

		return null;
	}

	public void setPropertyValue(Object id, Object value) {
		if (PAGING.equals(id))
			setPaging((Boolean) value);
	}

	@Override
	public boolean isEmpty() {
		if (paging)
			return false;

		return true;
	}

	@Override
	public int getRemainWidth() {
		return getWidth() - MINIMUM_WIDTH;
	}

	@Override
	public int getRequireWidth() {
		return MINIMUM_WIDTH;
	}

}
